package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.MarriageVideo;

/**
 * 
 * @author 
 *
 */
@DAO
public interface MarriageVideoDAO{
	
	@SQL("SELECT * FROM MarriageVideo WHERE 1=1  AND marriageInforId=:t.marriageInforId, AND video=:t.video, AND type=:t.type, ORDER BY update_date DESC LIMIT :t.start,:t.end ")
    List<MarriageVideo> query(@SQLParam("t") MarriageVideo marriageVideo);
    
    @SQL("select * from MarriageVideo where id=:1")
    MarriageVideo queryById(String id);    
    
    @SQL("INSERT INTO MarriageVideo (marriageInforId,video,type,image,title) VALUES (:t.marriageInforId,:t.video,:t.type,:t.image,:t.title)")
    void create(@SQLParam("t") MarriageVideo marriageVideo);
	
	@SQL("UPDATE MarriageVideo SET marriageInforId=:t.marriageInforId,video=:t.video,type=:t.type,image=:t.image,title=:t.title WHERE id=:t.id")
    void update(@SQLParam("t") MarriageVideo marriageVideo);
    
    @SQL("DELETE from MarriageVideo WHERE id=:1")
    void deleteById(String id);
    
    @SQL("select * from MarriageVideo where marriageInforId=:t.marriageInforId ORDER BY type DESC LIMIT :t.start,:t.length")
    List<MarriageVideo> queryByMarriageInforId(@SQLParam("t") MarriageVideo marriageVideo);

    @SQL("select count(1) from MarriageVideo where marriageInforId=:t.marriageInforId")
	int queryCntByMarriageInforId(@SQLParam("t") MarriageVideo marriageVideo);
    
    @SQL("select * from MarriageVideo where marriageInforId=1 #if(:t.title!=''){ and title like '%##(:t.title)%'} ORDER BY type DESC LIMIT :t.start,:t.length")
    List<MarriageVideo> queryByVideo(@SQLParam("t") MarriageVideo marriageVideo);

    @SQL("select count(1) from MarriageVideo where marriageInforId=1 #if(:t.title!=''){ and title like '%##(:t.title)%'} ")
	int querySizeByVideo(@SQLParam("t") MarriageVideo marriageVideo);
}